﻿using System;
using System.Collections.Generic;
using System.Windows;
using Tisbi.LawFirm.DAL.Models;

namespace Tisbi.LawFirm.BL.Services.Implementation.Mock
{
    public class MockCourtServiceAgent : MockServiceAgentBase<Court>
    {
        private List<Court> Courts;
        private List<District> Districts; 

        public MockCourtServiceAgent()
        {
            new MockDistrictServiceAgent().GetItem(GetDistrictCompleate);

            // Mock Court
            Courts = new List<Court>
            {
                new Court
                {
                    Id = 1,
                    Title = "Арбитражный суд Республики Татарстан",
                    Phone = "+8432666888",
                    Fax = "+8432666888",
                    Email = "arb@rt.ru",
                    Site = "arb.tat.ru",
                    Country = "Россия",
                    City = "Казань",
                    District = Districts[0],
                    ZipCode = 420100,
                    Street = "Кремль",
                    House = "2",
                    Housing = "1",
                    CourtEmployees =
                        new CourtEmployees
                        {
                            Id = 1,
                            Post = "Судья",
                            Surname = "Мусин",
                            Name = "Юлдаш",
                            Patronymic = "Сайдашович",
                            Phone = "8432946132",
                            Fax = ""
                        },
                    Jurisdiction = new Jurisdiction {Id = 1, District = Districts[0]}
                },
                new Court
                {
                    Id = 2,
                    Title = "Ново-Савиновский районный суд",
                    Phone = "+8432666888",
                    Fax = "+8432666888",
                    Email = "nss@rt.ru",
                    Site = "nss.tat.ru",
                    Country = "Россия",
                    City = "Казань",
                    District = Districts[0],
                    ZipCode = 420100,
                    Street = "Короленко",
                    House = "58",
                    Housing = "а",
                    CourtEmployees =
                        new CourtEmployees
                        {
                            Id = 1,
                            Post = "Судья",
                            Surname = "Хлебков",
                            Name = "Александр",
                            Patronymic = "Петрович",
                            Phone = "843555997",
                            Fax = ""
                        },
                    Jurisdiction = new Jurisdiction {Id = 1, District = Districts[0]}
                }
            };
        }

        private void GetDistrictCompleate(List<District> districts, Exception exception)
        {
            Districts = districts;
        }

        public override void GetItem(Action<List<Court>, Exception> completed)
        {
            try
            {
                completed(Courts, null);
            }
            catch (Exception ex)
            {
                completed(null, ex);
            }
        }

        public override void AddItem(Court item, Action<Exception> completed)
        {
            Courts.Add(item);
        }

        public override void RemoveItem(Court item)
        {
            Courts.Remove(item);
        }

        public override void Edit(Court item, Action<Exception> completed)
        {
            MessageBox.Show("Edit not implemented");
        }
    }
}
